<?php

namespace Summer\Slideshow\Http\Controllers;

use Illuminate\Routing\Controller;
use RLuders\JWTAuth\Classes\JWTAuth;
use Summer\Hjd\Http\Requests\RgRecordCreateRequest;
use Summer\Hjd\Models\RgRecordModel;
use Summer\Hjd\Models\RgRuleModel;
use Summer\Hub\Http\Controllers\Traits\ApiReturn;
use Input;
use Config;
use Db;
use Exception;
use Summer\Slideshow\Models\SlideModel;
use Summer\Slideshow\Models\SlideshowModel;
use System\Models\File as FileModel;


class SlideController extends Controller
{
    use ApiReturn;

    /**
     * 充值记录
     */
    public function index()
    {
        if(!Input::has('slug')){
            return $this->apiError('缺少标识参数');
        }
        $slug=Input::get('slug');
        $slideshow_id=SlideshowModel::where('slug',$slug)->value('id');
        if(!$slideshow_id){
            return $this->apiError('参数错误');
        }
        $query=SlideModel::select();
        $query->with(['cover']);
        $query->where('status',1);
        $query->where('slideshow_id',$slideshow_id);
        $query->orderBy('sort_order','DESC');
        $records=$query->get();
        $return['records']=$records;
        return $this->apiSuccess('操作成功',$return);
    }
}
